Namespace Code

    Module GlobalModule1
        'Public gsMyMainStates As String
        'Public gsMyTaskStates As String        
        Public oNetworkUser As BusinessLogicLayer.NetworkUser
        Public Enum RIBSState
            Allocated
            Unallocated
        End Enum

        Sub SecurityMessage()
            MsgBox("Security setting will not allow this action!", MsgBoxStyle.Exclamation, "Security")
        End Sub

        Function GetSystemFilter(ByVal ActionList As String, ByVal StatusList As String, ByVal UserList As String, Optional ByVal bWhere As Boolean = False) As String
            Dim SQL As String = ""
            Try
                'If ActionList = "" Then ActionList = RIBSState.Allocated.ToString & ","
                'If StatusList = "" Then StatusList = RIBSState.Unallocated.ToString & ","
                If ActionList.Length > 0 And StatusList.Length > 0 And UserList.Length > 0 Then

                    Dim lActions() As String = Split(ActionList, ",")
                    Dim lStatus() As String = Split(StatusList, ",")
                    Dim lUserList() As String = Split(UserList, ",")
                    'and (RibsState ='Allocated' )
                    Dim st As String
                    If bWhere Then
                        SQL = " ("
                    Else
                        SQL = " AND ("
                    End If

                    If lActions.Length > 1 Then

                        'SQL += " ( Action is null "

                        For Each st In lActions
                            If st <> "" Then
                                If Right$(SQL, 1) <> "(" Then
                                    SQL += " OR "
                                End If
                                SQL += " Action ='" & st & "'"
                            End If
                        Next
                        SQL += " ) "
                    End If

                    If lStatus.Length > 1 Then
                        SQL += " AND ("  'RibsState is null "

                        For Each st In lStatus
                            If st <> "" Then
                                If Right$(SQL, 1) <> "(" Then
                                    SQL += " OR "
                                End If
                                SQL += " RibsState ='" & st & "'"
                            End If
                        Next
                        SQL += " ) "
                    End If

                    'UserList
                    If lUserList.Length > 1 Then
                        SQL += " AND (" 'UserID IS Null "
                        For Each st In lUserList
                            If st <> "" Then
                                If Right$(SQL, 1) <> "(" Then
                                    SQL += " OR "
                                End If
                                SQL += " UserID ='" & st & "'"
                            End If
                        Next
                        SQL += " ) "
                    End If
                    'SQL += "AND (Ribs.AMOUNT_DUE >= [LETTER_Code].[MinDisplay] )"
                    'SQL += " )"
                End If
            Catch ex As Exception
                Throw ex
            End Try
            Return SQL
        End Function

        Function dbDateFormat(ByVal dDate As Date) As String
            Try
                Dim rtStr As String = "#" & Microsoft.VisualBasic.Day(dDate) & " " & MonthName(Month(dDate)) & " " & Year(dDate) & "#"
                Return rtStr
            Catch ex As Exception
                Throw ex
            End Try
        End Function


    End Module

End Namespace